import { View } from "../../../mvc/core/View";
import { IUpdateMagicWeaponInfo } from "./IUpdateMagicWeaponInfo";
import { Cache } from "../../cache/Cache";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Language } from "../../../../extend/language/Language";
import { MsgManager } from "../../manager/MsgManager";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { MagicWeaponConfig } from "../../resource/MagicWeaponConfig";
import { GameConst } from "../../../component/gconst/GameConst";
import { ListEvent } from "../../../../fl/events/ListEvent";
import { MagicWeaponItemData } from "./MagicWeaponItemData";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../resource/ColorConfig";
import { MagicWeaponUpgradeItemRenderer } from "./renderer/MagicWeaponUpgradeItemRenderer";
import { ItemData } from "../../resource/info/ItemData";
import { MagicWeaponUtil } from "./MagicWeaponUtil";
import { UpgradeVo } from "./data/UpgradeVo";
import { EProp } from "../../../../Message/Public/EProp";
import { PulseSharedObject } from "../player/PulseSharedObject";
import { CheckBoxWin } from "../common/alertwins/CheckBoxWin";
import { AutoGuideClickChildNames } from "../common/guide/AutoGuideClickChildNames";
import { ToolStrengthenWindow } from "./ToolStrengthenWindow";
import { EColor } from "../../../../Message/Public/EColor";
import { ECategory } from "../../../../Message/Public/ECategory";
import { AttriAddEffect } from "../effect/AttriAddEffect";
import { SPlayerItem } from "../../../../Message/Public/SPlayerItem";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { BaseItem } from "../common/BaseItem";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { MWPropertyItemRenderer } from "./renderer/MWPropertyItemRenderer";
import { BaseProgressBar } from "../common/BaseProgressBar";
import { ResFileConst } from "../../resource/ResFileConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { DisplayUtil } from "../../../common/DisplayUtil";
import { SWFPlayer } from "../../scene/modle/SWFPlayer";
import { ModelType } from "../../scene/modle/data/ModelType";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../com/mui/controls/GButton";
import { FireTip } from "../common/item/FireTip";
import { MagicWeaponCache } from "../../cache/MagicWeaponCache";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { MAX_TIMES } from "../../../../this/_cache/MAX_TIMES";
type int = number;
//class MagicWeaponStrengthenPanel
    
    export  class MagicWeaponStrengthenPanel extends View implements IUpdateMagicWeaponInfo
    {
        constructor()
        {
            super();
            this._cache = Cache.instance.magicWeapon;
            this.init();
            return;
        }

        /* internal  */onResetHandler(arg1): void
        {
            var e;
            var onBtnClickHandler: Function;
            var surplusTime: int;

            var loc1;
            onBtnClickHandler = null;
            surplusTime = 0;
            e = arg1;
            onBtnClickHandler = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponResetUpgradeTime));
                }
                return;
            }
            if (this._cache.resetTimes > 0) 
            {
                surplusTime = this._cache.MAX_TIMES - this._cache.identifyTimes < 0 ? 0 : MAX_TIMES - this._cache.identifyTimes;
                Alert.show(Language.getStringByParam(27703, surplusTime), null, Alert.OK | Alert.CANCEL, null, onBtnClickHandler);
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(27702));
                return;
            }
            return;
        }

        /* internal  */onLoadResHandler(): void
        {
            var loc1=GlobalClass.getBitmap(ImagesConst.CurProperty);
            ObjCreate.setObjAttri(loc1, 114, 205, -1, -1, this);
            var loc2=GlobalClass.getBitmap(ImagesConst.NextProperty);
            ObjCreate.setObjAttri(loc2, 250, 205, -1, -1, this);
            return;
        }

        /* internal  */clean(arg1: Object /* flash.events.Event */=null): void
        {
            this._itemName.text = "";
            this._curPropertyLv.text = "";
            this._nextPropertyLv.text = "";
            this._curSelectWeapon = null;
            this._progressBar.setValue(0, 0, 0.98);
            this._curProperty.dataProvider = new DataProvider([]);
            this._nextProperty.dataProvider = new DataProvider([]);
            this.selectItem = null;
            this._bestMagicWeapon.itemData = null;
            return;
        }

        /* internal  */set surplusTimeAndMoney(arg1: int)
        {
            var loc2=null;
            var loc1=MagicWeaponConfig.instance.getItemByTypeLevel(7, arg1 + 1);
            if (loc1) 
            {
                this.spendMoney = loc1.color;
                if (loc1.color != 0) 
                {
                    if (this._cache.MAX_TIMES - arg1 <= 0) 
                    {
                        loc2 = "0";
                        this._promoteBtn.enabled = false;
                    }
                    else 
                    {
                        loc2 = String(this._cache.MAX_TIMES - arg1);
                    }
                    this.surplusTime = int(loc2);
                    this._promoteBtn.label = Language.getStringByParam(27657, loc2);
                }
                else 
                {
                    this._promoteBtn.label = Language.getStringByParam(27656, String(3 - arg1));
                    this._promoteBtn.enabled = true;
                }
            }
            else 
            {
                this.surplusTime = 0;
                this._promoteBtn.enabled = false;
                this.surplusTime = 0;
                this._promoteBtn.label = Language.getStringByParam(27657, "0");
            }
            return;
        }

        /* internal  */set spendMoney(arg1: int)
        {
            if (this._spendMoney) 
            {
                this._spendMoney.text = String(arg1);
            }
            return;
        }

        /* internal  */set upgradeAmuletScoreTimes(arg1: int)
        {
            if (arg1 >= GameConst.UpradeAmuletScoreMaxTimes) 
            {
                this._addScoreBtn.label = Language.getStringByParam(27640, 0);
                this._addScoreBtn.enabled = false;
            }
            else 
            {
                this._addScoreBtn.label = Language.getStringByParam(27640, GameConst.UpradeAmuletScoreMaxTimes - arg1);
                this._addScoreBtn.enabled = true;
            }
            return;
        }

        /* internal  */get spendMoney(): int
        {
            return int(this._spendMoney.text);
        }

        /* internal  */set surplusTime(arg1: int)
        {
            if (this._spendMoney) 
            {
                this._surplusTime.text = Language.getStringByParam(27674, String(arg1));
            }
            return;
        }

        /* internal  */onSelectItemHandler(arg1: ListEvent): void
        {
            var loc1=arg1.item as MagicWeaponItemData;
            if (loc1 && loc1.itemData) 
            {
                if (this._curSelectWeapon) 
                {
                    if (this._curSelectWeapon.uid == loc1.itemData.uid) 
                    {
                        return;
                    }
                }
                this._index = this._weaponList.dataProvider.getItemIndex(loc1);
                this._itemName.htmlText = HTMLUtil.addColor(loc1.itemData.name, ColorConfig.instance.getItemColor(loc1.itemData.color).color);
                this._curSelectWeapon = loc1.itemData;
                this.magicWeaponProperty(this._curSelectWeapon);
                this.selectItem = loc1;
                this._bestMagicWeapon.itemData = Cache.instance.magicWeapon.getBestMagicWeapon(loc1.itemData);
            }
            return;
        }

        /* internal  */set selectItem(arg1: MagicWeaponItemData)
        {
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc1=0;
            if (this._weaponList.dataProvider) 
            {
                loc2 = this._weaponList.dataProvider.length;
                while (loc1 < loc2) 
                {
                    loc3 = this._weaponList.dataProvider.getItemAt(loc1) as MagicWeaponItemData;
                    loc4 = this._weaponList.itemToCellRenderer(loc3) as MagicWeaponUpgradeItemRenderer;
                    if (loc3 && loc4) 
                    {
                        if (loc3 != arg1) 
                        {
                            loc4.selectItem = false;
                        }
                        else 
                        {
                            loc4.selectItem = true;
                        }
                    }
                    ++loc1;
                }
            }
            return;
        }

        /* internal  */magicWeaponProperty(arg1: ItemData, arg2: Boolean=false): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            if (MagicWeaponUtil.isNoPropertyWeapon(arg1)) 
            {
                this._curProperty.dataProvider = new DataProvider([]);
                this._nextProperty.dataProvider = new DataProvider([]);
                return;
            }
            if (arg1) 
            {
                loc1 = MagicWeaponUtil.nextLvProperty(arg1, arg1.color, arg1.magicWeaponLv, false, arg2);
                loc2 = MagicWeaponUtil.nextLvProperty(arg1, arg1.color, arg1.magicWeaponLv + 1, true, arg2);
                if (loc1) 
                {
                    this._curProperty.dataProvider = new DataProvider(loc1);
                    this._curProperty.drawNow();
                }
                if (loc2) 
                {
                    this._nextProperty.dataProvider = new DataProvider(loc2);
                    this._nextProperty.drawNow();
                }
                if (loc3 = MagicWeaponConfig.instance.getItemByTypeColorLevel(5, arg1.color, arg1.magicWeaponLv)) 
                {
                    loc4 = MagicWeaponConfig.instance.getMaxLvByTypeColor(4, arg1.color);
                    if (arg1.magicWeaponExp >= loc3.exp || arg1.magicWeaponLv >= loc4) 
                    {
                        this._progressBar.setValue(0, loc3.exp, 0.98);
                        this._progressBar.setText(Language.getString(27684));
                    }
                    else 
                    {
                        this._progressBar.setValue(arg1.magicWeaponExp, loc3.exp, 0.98);
                    }
                }
                this.setPropertyLv(arg1.magicWeaponLv, arg1.magicWeaponLv + 1);
            }
            return;
        }

        /* internal  */onPromoteHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var vo: UpgradeVo;
            var material: Array<any>;
            var isNeedAlert: Boolean;
            var onBtnClickHandler: Function;

            var loc1;
            vo = null;
            material = null;
            isNeedAlert = false;
            e = arg1;
            if (this._curSelectWeapon) 
            {
                vo = new UpgradeVo();
                if (this._isOpenByPackItem) 
                {
                    material = Cache.instance.pack.backPackCache.getUidListByType(this._packItem.category, this._packItem.type, this._packItem.effect);
                    if (material.length < 1) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(27683));
                        return;
                    }
                    if (this._packItem.type != EProp._EPropAmuletValueStone) 
                    {
                        if (this._packItem.type == EProp._EPropAmuletActiveItem) 
                        {
                            vo.opType = 2;
                        }
                    }
                    else 
                    {
                        vo.opType = 1;
                    }
                    vo.materials = [material[0]];
                }
                else 
                {
                    vo.opType = 0;
                    vo.materials = [];
                }
                vo.posType = this._curSelectWeapon.posType;
                vo.amuletUid = this._curSelectWeapon.uid;
                if (!this._isOpenByPackItem && this.spendMoney > 0) 
                {
                    onBtnClickHandler = (arg1: int, arg2: Boolean): void
                    {
                        if (arg1 == Alert.OK) 
                        {
                            Alert.resetToDefault();
                            Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponUpgrade, {"vo": vo}));
                            setPromoteBtnEnabled();
                        }
                        if (arg2) 
                        {
                            PulseSharedObject.save("StrengthenCost", true);
                        }
                        return;
                    }
                    isNeedAlert = !PulseSharedObject.isTodayNotTips("StrengthenCost");
                    if (isNeedAlert) 
                    {
                        Alert.alertWinRenderer = CheckBoxWin;
                        Alert.show(Language.getStringByParam(27651, this.spendMoney), null, Alert.OK | Alert.CANCEL, null, onBtnClickHandler);
                        return;
                    }
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponUpgrade, {"vo": vo}));
                this.setPromoteBtnEnabled();
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(27682));
            }
            return;
        }

        public updateWeaponInfo(): void
        {
            var loc5=0;
            var loc6=null;
            var loc1=new Array<any>();
            var loc2=Cache.instance.magicWeapon.hasIdentifyAndWear;
            loc1 = loc1.concat(loc2);
            var loc3=loc1.length;
            var loc4=Cache.instance.magicWeapon.holeNum;
            if (this._weaponList && loc1) 
            {
                loc5 = loc3;
                while (loc5 < 5) 
                {
                    loc1.push(new MagicWeaponItemData(null));
                    ++loc5;
                }
                loc5 = 0;
                while (loc5 < loc1.length) 
                {
                    if ((loc6 = loc1[loc5]) != null) 
                    {
                        if (loc5 != 0) 
                        {
                            loc6.name = "";
                        }
                        else 
                        {
                            loc6.name = AutoGuideClickChildNames.MagicWeapon_UpgradeItem1Name;
                        }
                        if (loc5 < loc4) 
                        {
                            loc6.isOpen = true;
                        }
                        else 
                        {
                            loc6.isOpen = false;
                        }
                        if (this._curSelectWeapon && loc6.itemData && this._curSelectWeapon.type == loc6.itemData.type && !(this._curSelectWeapon.uid == loc6.itemData.uid)) 
                        {
                            this.clean();
                        }
                    }
                    ++loc5;
                }
                this._weaponList.dataProvider = new DataProvider(loc1);
                this._weaponList.drawNow();
            }
            if (this._isOpenByPackItem) 
            {
                this.itemLabel = this._packItem;
                this._promoteBtn.enabled = true;
            }
            else 
            {
                this.surplusTimeAndMoney = this._cache.identifyTimes;
                this.tiredSaveBtnTip = this._cache.resetTimes;
                this.openByItemType = 0;
            }
            if (MagicWeaponUtil.isInUpgradeAmuletScore) 
            {
                this.upgradeAmuletScoreTimes = this._cache.upgradeAmuletScoreTimes;
            }
            return;
        }

        /* internal  */setPromoteBtnEnabled(arg1: Boolean=false): void
        {
            this._promoteBtn.enabled = arg1;
            if (arg1) 
            {
                flash.utils.clearTimeout(this.timerOutInerVer);
            }
            else 
            {
                this.timerOutInerVer = flash.utils.setTimeout(this.setPromoteBtnEnabled, 1200, true);
            }
            return;
        }

        /* internal  */onToolPromoteHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._curSelectWeapon == null) 
            {
                MsgManager.showRollTipsMsg(Language.getString(27682));
                return;
            }
            ToolStrengthenWindow.instance.showWindow(this._curSelectWeapon);
            return;
        }

        /* internal  */onClickAddScoreBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=0;
            if (this._curSelectWeapon) 
            {
                if (this._curSelectWeapon.color < EColor._EColorPurple) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(27642));
                }
                else 
                {
                    loc1 = Cache.instance.pack.backPackCache.getItemCountByCategoryAndType(ECategory._ECategoryProp, EProp._EPropUpgradeAmuletScore);
                    if (loc1 <= 0) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(27643));
                    }
                    else 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponAddScore, this._curSelectWeapon.uid));
                    }
                }
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(27641));
            }
            return;
        }

        /* internal  */setPropertyLv(arg1: int, arg2: int): void
        {
            this._curPropertyLv.text = Language.getStringByParam(27653, arg1.toString());
            this._nextPropertyLv.text = Language.getStringByParam(27653, arg2.toString());
            return;
        }

        /* internal  */set itemLabel(arg1: ItemData)
        {
            var loc1=0;
            if (arg1) 
            {
                loc1 = Cache.instance.pack.backPackCache.getItemCountByCategoryAndType(arg1.category, arg1.type, arg1.effect);
                this._itemLabel.htmlText = HTMLUtil.addColor(arg1.name + " * " + loc1.toString(), ColorConfig.instance.getItemColor(arg1.color).color);
            }
            else 
            {
                this._itemLabel.htmlText = "";
            }
            return;
        }

        /* internal  */set openByItemType(arg1: int)
        {
            var loc1=false;
            if (arg1 != 0) 
            {
                this._fireTip.visible = false;
                this._surplusTime.visible = false;
                this._spendMoney.visible = false;
                this._toolPromoteBtn.visible = false;
                this._spendDec.visible = false;
                this._tiredSaveBtn.visible = false;
                this._resetTimeTxt.visible = false;
                if (arg1 == EProp._EPropAmuletValueStone || arg1 == EProp._EPropAmuletActiveItem) 
                {
                    this._promoteBtn.visible = true;
                    this._itemLabel.visible = true;
                    this._addScoreBtn.visible = false;
                }
                else if (EProp._EPropUpgradeAmuletScore) 
                {
                    this._addScoreBtn.visible = true;
                    this._itemLabel.visible = false;
                    this._promoteBtn.visible = false;
                    this.upgradeAmuletScoreTimes = this._cache.upgradeAmuletScoreTimes;
                }
            }
            else 
            {
                loc1 = Cache.instance.magicWeapon.isInActive;
                this._promoteBtn.visible = true;
                this._itemLabel.visible = false;
                this._fireTip.visible = true;
                this._tiredSaveBtn.visible = true;
                this._resetTimeTxt.visible = true;
                this._toolPromoteBtn.visible = loc1;
                this._addScoreBtn.visible = MagicWeaponUtil.isInUpgradeAmuletScore;
                this.setBtnStyle();
                if (this.spendMoney > 0) 
                {
                    this._surplusTime.visible = true;
                    this._spendMoney.visible = true;
                    this._spendDec.visible = true;
                }
                else 
                {
                    this._surplusTime.visible = false;
                    this._spendMoney.visible = false;
                    this._spendDec.visible = false;
                }
                if (loc1 || MagicWeaponUtil.isInUpgradeAmuletScore) 
                {
                    this._surplusTime.visible = false;
                    this._spendDec.x = 75;
                    this._spendDec.y = 398;
                    this._spendMoney.x = 151;
                    this._spendMoney.y = 398;
                }
                else 
                {
                    this._spendDec.x = 60;
                    this._spendDec.y = 430;
                    this._spendMoney.x = 140;
                    this._spendMoney.y = 430;
                }
            }
            return;
        }

        /* internal  */clickHelpHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponShowPageGuide));
            return;
        }

        /* internal  */setBtnStyle(): void
        {
            if (this._promoteBtn.visible && this._toolPromoteBtn.visible && this._addScoreBtn.visible) 
            {
                this._promoteBtn.x = 75;
                this._toolPromoteBtn.x = 180;
                this._addScoreBtn.x = 285;
                this._tiredSaveBtn.x = 318;
                this._resetTimeTxt.x = 340;
                this._tiredSaveBtn.y = 170;
                this._resetTimeTxt.y = 173;
            }
            else if (this._promoteBtn.visible && this._toolPromoteBtn.visible && this._addScoreBtn.visible == false) 
            {
                this._promoteBtn.x = 75;
                this._toolPromoteBtn.x = 208;
                this._tiredSaveBtn.x = 300;
                this._resetTimeTxt.x = 324;
                this._tiredSaveBtn.y = 418;
                this._resetTimeTxt.y = 423;
            }
            else if (this._promoteBtn.visible && this._addScoreBtn.visible && this._toolPromoteBtn.visible == false) 
            {
                this._promoteBtn.x = 75;
                this._addScoreBtn.x = 180;
                this._tiredSaveBtn.x = 300;
                this._resetTimeTxt.x = 324;
                this._tiredSaveBtn.y = 418;
                this._resetTimeTxt.y = 423;
            }
            return;
        }

        /* internal  */playCriEffect(arg1: int): void
        {
            var loc1=new Object /* flash.geom.Point */(this._progressBar.x + this._progressBar.width / 2, this._progressBar.y - 40);
            var loc2=localToGlobal(loc1);
            AttriAddEffect.attriAdd(arg1, loc2.x, loc2.y, true);
            return;
        }

        public openByPackItem(arg1: ItemData=null): void
        {
            if (arg1) 
            {
                this.openByItemType = arg1.type;
                this._isOpenByPackItem = true;
                this._promoteBtn.x = 175;
                this._promoteBtn.label = Language.getString(27655);
            }
            else 
            {
                this._promoteBtn.x = Cache.instance.magicWeapon.isInActive ? 75 : 175;
                this.openByItemType = 0;
                this._isOpenByPackItem = false;
            }
            this._packItem = arg1;
            this.itemLabel = this._packItem;
            return;
        }

        public upgradeSucceed(arg1: Array<any>, arg2: int, arg3: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            if (arg1) 
            {
                if (!this._isOpenByPackItem) 
                {
                    if (Cache.instance.magicWeapon.isOpenByTool) 
                    {
                        Cache.instance.magicWeapon.isOpenByTool = false;
                    }
                    else if (arg2 > 0 || arg3) 
                    {
                        var loc4;
                        var loc5=((loc4 = this._cache).identifyTimes + 1);
                        loc4.identifyTimes = loc5;
                        this.surplusTimeAndMoney = this._cache.identifyTimes;
                    }
                }
                this.setPromoteBtnEnabled(true);
                loc2 = arg1[0] as SPlayerItem;
                loc1 = new ItemData(loc2);
                if (arg3) 
                {
                    this.playCriEffect(arg2);
                }
                else if (arg2 > 0) 
                {
                    MsgManager.showRollTipsMsg("+" + arg2);
                }
                if ((loc3 = this._weaponList.dataProvider.getItemAt(this._index) as MagicWeaponItemData) && loc1.magicWeaponLv - loc3.itemData.magicWeaponLv > 0) 
                {
                    this.playEffect();
                    this.magicWeaponProperty(loc1, true);
                }
                else 
                {
                    this.magicWeaponProperty(loc1);
                }
                if (loc3 && loc1.magicWeaponScore - loc3.itemData.magicWeaponScore > 0) 
                {
                    this._bestMagicWeapon.itemData = Cache.instance.magicWeapon.getBestMagicWeapon(loc1);
                }
            }
            else 
            {
                this.setPromoteBtnEnabled(true);
            }
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(19, 61, 400, 427, this);
            var loc1=new GImageBitmap(ImagesConst.MagicWeaponBg, 45, 170);
            this.addChild(loc1);
            ObjCreate.createBg(30, 160, 380, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(30, 450, 380, 2, this, ImagesConst.SplitLine);
            var loc2=new GImageBitmap("Label_jipingyulang.png", 17, 165);
            this.addChild(loc2);
            ObjCreate.createBg(31, 190, 50, 49, this, ImagesConst.equipment_boarder);
            this._bestMagicWeapon = new BaseItem();
            ObjCreate.setObjAttri(this._bestMagicWeapon, 40, 200, 32, 32, this);
            this._weaponList = ObjCreate.createTileList(27, 65, 400, 78, this);
            this._weaponList.scrollPolicy = ScrollPolicy.OFF;
            this._weaponList.columnWidth = 76;
            this._weaponList.rowHeight = 76;
            this._weaponList.setStyle("cellRenderer", MagicWeaponUpgradeItemRenderer);
            this._weaponList.addEventListener(ListEvent.ITEM_CLICK, this.onSelectItemHandler);
            ObjCreate.createBitmap(ImagesConst.VSpliteLine, 108, 60, this);
            ObjCreate.createBitmap(ImagesConst.VSpliteLine, 183, 60, this);
            ObjCreate.createBitmap(ImagesConst.VSpliteLine, 259, 60, this);
            ObjCreate.createBitmap(ImagesConst.VSpliteLine, 336, 60, this);
            var loc3=ObjCreate.createBg(164, 169, 120, 25, this, ImagesConst.FightingStrgBg);
            loc3.alpha = 0.5;
            this._itemName = ObjCreate.createGTextField("", 164, 174, 120, 25, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1));
            ObjCreate.createBg(90, 200, 130, 170, this);
            ObjCreate.createBg(227, 200, 130, 170, this);
            this._curPropertyLv = ObjCreate.createGTextField("", 130, 174, 60, 20, this, GlobalStyle.textFormat6);
            this._nextPropertyLv = ObjCreate.createGTextField("", 275, 174, 60, 20, this, GlobalStyle.textFormat5);
            this._curProperty = ObjCreate.createTileList(110, 225, 80, 200, this);
            this._curProperty.scrollPolicy = ScrollPolicy.OFF;
            this._curProperty.columnWidth = 100;
            this._curProperty.rowHeight = 22;
            this._curProperty.setStyle("cellRenderer", MWPropertyItemRenderer);
            this._nextProperty = ObjCreate.createTileList(245, 225, 130, 200, this);
            this._nextProperty.scrollPolicy = ScrollPolicy.OFF;
            this._nextProperty.columnWidth = 130;
            this._nextProperty.rowHeight = 22;
            this._nextProperty.setStyle("cellRenderer", MWPropertyItemRenderer);
            this._progressBar = new BaseProgressBar(ImagesConst.ProgressBarBg);
            this._progressBar.setSize(270, 14);
            this._progressBar.isScale = true;
            this._progressBar.progressBarClass = ImagesConst.EnergyBar;
            this._progressBar.setProgressPosition(3, 3);
            this._progressBar.x = 90;
            this._progressBar.y = 385;
            this._progressBar.setValue(0, 100, 0.98);
            this.addChild(this._progressBar);
            this._promoteBtn = ObjCreate.createGButton("", 178, 415, 90, 28, this, "ButtonRed");
            this._promoteBtn.name = AutoGuideClickChildNames.MagicWeapon_UpgradeBtnName;
            this._promoteBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onPromoteHandler);
            this._toolPromoteBtn = ObjCreate.createGButton(Language.getString(27655), 208, 415, 90, 28, this, "ButtonRed");
            this._toolPromoteBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onToolPromoteHandler);
            this._addScoreBtn = ObjCreate.createGButton(Language.getStringByParam(27640, 3), 300, 415, 90, 28, this, "ButtonRed");
            this._addScoreBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onClickAddScoreBtnHandler);
            this._surplusTime = ObjCreate.createGTextField(Language.getStringByParam(27674, ""), 60, 410, 100, 20, this, GlobalStyle.textFormat6);
            this._spendDec = ObjCreate.createGTextField(Language.getString(27675), 60, 430, 90, 20, this, GlobalStyle.textFormat6);
            this._spendMoney = ObjCreate.createGTextField("", 140, 430, 28, 20, this, GlobalStyle.textFormat6);
            this._itemLabel = ObjCreate.createGTextField("", 275, 423, 140, 20, this, GlobalStyle.textFormat6);
            this._fireTip = ObjCreate.createFireTip(Language.getString(27658), 30, 455, this, true);
            var loc4;
            (loc4 = ObjCreate.createImgBtn(ImagesConst.RuleExplain, 350, 460, 60, 23, this, "Button")).gbutton.toolTipData = Language.getString(27677);
            loc4.gbutton.addEventListener(flash.events.MouseEvent.CLICK, this.clickHelpHandler);
            this._tiredSaveBtn = ObjCreate.createGLoadedButton(ResFileConst.PackAdd, 300, 418, 23, 23, this);
            this._tiredSaveBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onResetHandler);
            this._resetTimeTxt = ObjCreate.createGTextField("", 324, 423, 60, 20, this, GlobalStyle.textFormat6);
            this._resetTimeTxt.htmlText = Language.getStringByParam(27688, "0");
            this._resetTimeTxt.addEventListener(flash.events.TextEvent.LINK, this.onResetHandler);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.clean);
            LoaderHelp.addResCallBack(ResFileConst.magicWeapon, this.onLoadResHandler);
            return;
        }

        public playEffect(): void
        {
            var removeEffect: Function;

            var loc1;
            removeEffect = null;
            removeEffect = (): void
            {
                _effectPlayer.stop();
                DisplayUtil.removeMe(_effectPlayer);
                return;
            }
            if (this._effectPlayer == null) 
            {
                this._effectPlayer = new SWFPlayer();
                this._effectPlayer.scaleX = 0.88;
            }
            this._effectPlayer.load("fightSpiritLevelUpShine.swf", ModelType.NormalSwf, null);
            this._effectPlayer.move(221, 392);
            this._effectPlayer.play();
            if (!this._effectPlayer.parent) 
            {
                this.addChildAt(this._effectPlayer, (this.numChildren - 1));
                flash.utils.setTimeout(removeEffect, 2000);
            }
            return;
        }

        /* internal  */set tiredSaveBtnTip(arg1: int)
        {
            this._resetTimeTxt.htmlText = Language.getStringByParam(27705, arg1);
            this._resetTimeTxt.toolTipData = Language.getStringByParam(27701, arg1);
            this._tiredSaveBtn.toolTipData = Language.getStringByParam(27701, arg1);
            return;
        }

        /* internal */ /* var */_weaponList: GTileList;

        /* internal */ /* var */_curPropertyLv: GTextFiled;

        /* internal */ /* var */_nextPropertyLv: GTextFiled;

        /* internal */ /* var */_curProperty: GTileList;

        /* internal */ /* var */_nextProperty: GTileList;

        /* internal */ /* var */_toolPromoteBtn: GButton;

        /* internal */ /* var */_addScoreBtn: GButton;

        /* internal */ /* var */_curSelectWeapon: ItemData;

        /* internal */ /* var */_progressBar: BaseProgressBar;

        /* internal */ /* var */_surplusTime: GTextFiled;

        /* internal */ /* var */_spendMoney: GTextFiled;

        /* internal */ /* var */_spendDec: GTextFiled;

        /* internal */ /* var */_itemName: GTextFiled;

        /* internal */ /* var */_fireTip: FireTip;

        /* internal */ /* var */_effectPlayer: SWFPlayer;

        /* internal */ /* var */_packItem: ItemData;

        /* internal */ /* var */_itemLabel: GTextFiled;

        /* internal */ /* var */_isOpenByPackItem: Boolean;

        /* internal */ /* var */_resetTimeTxt: GTextFiled;

        /* internal */ /* var */_bestMagicWeapon: BaseItem;

        /* internal */ /* var */_index: int;

        /* internal */ /* var */_cache: MagicWeaponCache;

        /* internal */ /* var */_promoteBtn: GButton;

        /* internal */ /* var */_tiredSaveBtn: GLoadedButton;

        /* internal */ /* var */timerOutInerVer: uint;
    }
